package com.gaofans.nrpc.common.processor;

import reactor.core.publisher.MonoSink;

import java.util.Objects;

/**
 * @author GaoFans
 */
public class SingleSink<T> implements Sink<T>{

    private final MonoSink<T> sink;

    public SingleSink(MonoSink<T> sink) {
        this.sink = Objects.requireNonNull(sink);
    }

    @Override
    public Sink<T> next(T t) {
        sink.success(t);
        return this;
    }

    @Override
    public void complete() {
        //do nothing
    }

    @Override
    public void error(Throwable throwable) {
        sink.error(throwable);
    }
}
